export function toBoolean(val: any) {
    if (val == null) {
        return false;
    }

    if (typeof val == 'boolean') {
        return val;
    }

    if (typeof val == 'number') {
        return val != 0;
    }

    if (typeof val == 'string') {
        return ("" + val).trim() == ""; // 空字符串当做false
    }

    return true;
}